import matplotlib.pyplot as plt
import numpy as np
import sys

# https://blog.csdn.net/gongdiwudu/article/details/129947219

def t1():
    population_ages = [22,55,62,45,21,22,34,42,42,4,99,102,
                   110,120,121,122,130,111,115,112,80,75,
                   65,54,44,43,42,48]
    x=range(0, len(population_ages))
    # s:点的直径，c: 点的颜色，默认蓝色'b', marker： 点的样式，默认o
    plt.scatter(x, population_ages, label='first label', s=20)
    #help(plt.scatter)
    plt.xlabel('x')
    plt.ylabel('y')
    plt.title('Interesting Graph\nCheck it out')
    plt.legend()  # 需调用才会显示label
    plt.show()

def t2():
    # Fixing random state for reproducibility
    np.random.seed(19680801)
    
    N = 50
    x = np.random.rand(N)
    y = np.random.rand(N)
    colors = np.random.rand(N)          # 颜色可以随机
    print('color:', colors[:10])
    area = (30 * np.random.rand(N))**2  # 点的宽度30，半径15
    
    # c 取一维数据时，各点是如何决定是什么颜色 ？ 由cmap 参数决定，如果还指定了归一化函数norm，先归一化再应用cmap
    plt.scatter(x, y, s=area, c=colors, alpha=0.5)  
    plt.show()

#t1()
#t2()